package com.zjm.servlet.servlet03_three_ways;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author ZJM
 * @date 2024/4/11 22:15
 * 方式3：继承javax.servlet.http.HttpServlet抽象类
 * <p>
 * 重写父类中的方法，通常会重写doGet()和doPost()等方法来处理不同类型的HTTP请求。
 */
public class Way03Servlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out = resp.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + "方式3：继承javax.servlet.http.HttpServlet抽象类" + "</h1>");
        out.println("</body></html>");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
}
